import $ from "jquery";
import {url} from "../../util/config";
import {message} from "antd";
import login from "../login";
function getNewLogin(items) {
    return deleteNotice(items)
}
export default function deleteNotice(items) {

    console.log("deleteRole",items)

    let token = localStorage.getItem("token")

    let status;
    $.ajax({
        async:false,
        headers: {
            'Accept': "application/json",
            'Authorization': token
        },
        url: url.api_url+`Notice/DelNoticeContent`,
        type: 'POST',
        contentType:"application/json",
        data: JSON.stringify({ID:items}),
        success: function (result) {
            if(result.result=="Token過期請重新登錄"){
                login(localStorage.getItem("account"), localStorage.getItem("password"));
                status = getNewLogin(items)
            }else {
                status = result.result
                if(status=="ok"){
                    message.success("删除成功")
                }else {
                    message.error("删除失败")
                }
            }
        },
        error:function (error) {
            status = "error"
            message.error("请求异常")
        }
    })
    return status;
    // return "ok"
}
